
/***************** Modification History ***********************************
   @doc
   @module SCT.c - Service Codes Table maintenance functions |
   @end
   
$Log: /SoftPay/SPK2SIM/Source/Card/sct.c $ 
**************************************************************************

   Copyright (C) 1999 by VeriFone, Inc.

   All rights reserved.  No part of this software may be reproduced,
   transmitted, transcribed, stored in a retrieval system, or translated
   into any language or computer language, in any form or by any means,
   electronic, mechanical, magnetic, optical, chemical, manual or otherwise,
   without the prior written permission of VeriFone, Inc.

---------------------------------------------------------------------------*/

#include <project.h>

#ifdef CARD_DEFINED

#define VSSCT_C

#include <stdio.h>
#include <string.h>

/** /#define DEBUG_VSSCT */
#ifdef DEBUG_VSSCT
#define DEBUG_95
#endif

#include <define.h>
#include <sizes.h>
#include <confio.h>
#include <transact.h>
#include <cdt.h>
#include <tct.h>
#include <opedit.h>
#include <msg.h>
#include <ui.h>
#include <pscalls.h>
#include <msgfuncs.h>
#include <sct.h>
#include <cardmsg.h>
#include <spdebug.h>
#include <util.h>
#include <file.h>

/*-------------------------------------------------------------------------
    Function :  inGetSCTTotRecs()
    Description : Determines the number of records in the SCT file
    Parameters : n/a
    Returns : Number of records.
    Globals : 
    Notes : 
    Modification History :
      #     Date      Who                     Description
    ----- -------- ---------- ---------------------------------------------
      0   09/01/98 Page_K1    Creation...
--------------------------------------------------------------------------*/

int inGetSCTTotRecs() {
    long lnSize;

    /** /pdebug(("--inGetSCTTotRecs--"));*/

    lnSize = lnGetFileSize(SCT_FILE_NAME);
    return((int) ((lnSize - GEN_VER_SIZE) / (long) SIZE_SCT_REC));
}

/*-------------------------------------------------------------------------
    Function :  inSetSCTTemplateSuffix()
    Description : Sets the field szTemplateFileNameSuffix in the SCT file
                    to value determined by the printer type
    Parameters : n/a
    Returns : Number of records.
    Globals : 
    Notes : 
    Modification History :
      #     Date      Who                     Description
    ----- -------- ---------- ---------------------------------------------
      0   09/01/98 Page_K1    Creation...
--------------------------------------------------------------------------*/
VS_BOOL fIsINTERAC(char* pszServiceCode) {
    int inSCTCount,
    inCount;
    VS_BOOL fRetVal = VS_FALSE;
    SCT_REC srSCTRec;


    /**/pdebug(("Service Code=%c%c%c", pszServiceCode[0], pszServiceCode[1], pszServiceCode[2]));/**/
    inSCTCount = inGetSCTTotRecs();
    for (inCount = 0; inCount < inSCTCount; inCount++) {
        /* Load SERVICE CODE record */
        if (inLoadConfRec(SCT_FILE_NAME, SIZE_SCT_REC, inCount, (char *) &srSCTRec) != VS_SUCCESS) {
            vdDisplayMessageFromFile(SCT_ERR_MSG21, ERROR_MSG);
            break;
        }

        if (strncmp(pszServiceCode, srSCTRec.szServiceCode, 3) == 0) {
            fRetVal = VS_TRUE;
            break;
        }
    }
    return (fRetVal);
}

int inEditSCTOperation(TRANSACTION_OBJECT* pobTran) {
    inConfRecEdit("SCT");
    return(BRANCH_EXIT);
}

#undef VSSCT_C

#endif
